import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'en_US.dart';
import 'zh_CN.dart';

enum LocaleType {
  zh,
  en,
}

class TranslationService extends Translations {
  static Locale? get locale => Get.deviceLocale;
  static const fallbackLocale = Locale('zh', 'CN');

  @override
  Map<String, Map<String, String>> get keys => {
        'zh_CN': zh_CN,
        'en_US': en_US,
      };
}

// 跟随系统语言
void settingSystemLanguage() {
  if (Get.deviceLocale?.languageCode == 'zh') {
    Get.updateLocale(const Locale('zh', 'CN'));
  } else if (Get.deviceLocale?.languageCode == 'en') {
    Get.updateLocale(const Locale('en', 'US'));
  } else {
    // 跟随系统语言
    // Get.updateLocale(window.locale);
    // Get.updateLocale(View.of(Get.context!).lo);
  }
}
